package event.motor

import app.AppContext
import com.hontech.pizzav2.R

class DeliveryChangedEvent(val col: Int, val row: Int, val state: Int) : MotorCode() {

    companion object {
        const val Take1 = 0x90 // 取货 + 预热 + 加热 + 出货
        const val Take2 = 0x8F // 取货 + 加热 + 出货
        const val Take3 = 0x91 // 取货 + 出货
        const val Preheat = 0x92
        const val Heat = 0x93
        const val Deliver = 0x94
        const val Complete = 0x95

        const val Success = 0xA7
        const val Error = 0xA8
    }

    fun status(): String {
        val arr = AppContext.resources.getStringArray(R.array.return_value)
        return when (state) {
            Take1, Take2, Take3 -> "Taking"
            Preheat -> "Preheating"
            Heat -> "Heating"
            Deliver -> "Delivering"
            Success -> "Success"
            Error -> "Error"
            Complete -> "Complete"
            in OK..PICK_ERROR2 -> arr[state]
            else -> "Error"
        }
    }
}